package com.ljf.daily.consumptiondetail.web;

import com.ljf.common.exception.ServiceException;
import com.ljf.common.result.ResultModel;
import com.ljf.common.utils.DateUtil;
import com.ljf.common.web.BasisController;
import com.ljf.daily.consumptiondetail.dto.command.DailyDatConsumptionDetailCommand;
import com.ljf.daily.consumptiondetail.dto.command.DailyDatConsumptionDetailGenerateDataCommand;
import com.ljf.daily.consumptiondetail.dto.query.DailyDatConsumptionDetailQuery;
import com.ljf.daily.consumptiondetail.service.IDailyDatConsumptionDetailService;
import com.ljf.daily.consumptiondetail.vo.DailyDatConsumptionDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 日常消费明细  控制器
 *
 * @author LJF
 * @since 2024-05-10
 */
@RestController
@RequestMapping("/daily/dat/consumption_detail")
@Api(value = "日常消费明细接口", tags = "日常消费明细接口")
public class DailyDatConsumptionDetailController extends BasisController<IDailyDatConsumptionDetailService, DailyDatConsumptionDetailQuery, DailyDatConsumptionDetailVO, DailyDatConsumptionDetailCommand> {

    @PostMapping("/generate_data")
    @ApiOperation(value = "生成数据接口")
    public ResultModel generateData(@RequestBody DailyDatConsumptionDetailGenerateDataCommand command) throws ServiceException {
        return service.generateData(command);
    }

    @GetMapping("/edit_data")
    @ApiOperation(value = "获取更新数据")
    public ResultModel editData(String belongDate, String dayConsumption) throws ServiceException {
        return service.editData(DateUtil.parseDate(belongDate), dayConsumption);
    }

}